package com.boot.security.server.dao.level;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.level.TswLevel;

@Mapper
public interface TswLevelDao {

    @Select("select * from tsw_level t where t.id = #{id}")
    TswLevel getById(Long id);

    @Delete("delete from tsw_level where id = #{id}")
    int delete(Long id);

    int update(TswLevel tswLevel);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_level(level_parent_id, level_name, level_image_path, total_amount_required, level_discount, state, create_time, level_sorting, creater, update_time, updater, level_note, level_remark) values(#{levelParentId}, #{levelName}, #{levelImagePath}, #{totalAmountRequired}, #{levelDiscount}, #{state}, #{createTime}, #{levelSorting}, #{creater}, #{updateTime}, #{updater}, #{levelNote}, #{levelRemark})")
    int save(TswLevel tswLevel);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswLevel> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
